package com.qipay.mapper;

import com.qipay.baas.model.Sp;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;
import java.util.Map;

@Mapper
public interface SpMapper extends com.qipay.baas.mapper.SpMapper {

    @Select({
            "select",
            "id, name, service,bank, update_date, create_date,state,delete_flag,mch_id,card_no",
            "from sp"
    })
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
            @Result(column = "service", property = "service", jdbcType = JdbcType.VARCHAR),
            @Result(column = "bank", property = "bank", jdbcType = JdbcType.VARCHAR),
            @Result(column = "update_date", property = "updateDate", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "create_date", property = "createDate", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "state", property = "state", jdbcType = JdbcType.TINYINT),
            @Result(column = "delete_flag", property = "deleteFlag", jdbcType = JdbcType.TINYINT),
            @Result(column = "card_no", property = "cardNo", jdbcType = JdbcType.VARCHAR),
            @Result(column = "mch_id", property = "mchId", jdbcType = JdbcType.BIGINT)
    })
    List<Sp> selectAll();

    @SelectProvider(type = SpSqlProvider.class, method = "countByCondition")
    long countByCondition(Map<String, Object> params);

    @SelectProvider(type = SpSqlProvider.class, method = "selectByCondition")
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
            @Result(column = "service", property = "service", jdbcType = JdbcType.VARCHAR),
            @Result(column = "bank", property = "bank", jdbcType = JdbcType.VARCHAR),
            @Result(column = "update_date", property = "updateDate", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "create_date", property = "createDate", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "state", property = "state", jdbcType = JdbcType.TINYINT),
            @Result(column = "delete_flag", property = "deleteFlag", jdbcType = JdbcType.TINYINT),
            @Result(column = "card_no", property = "cardNo", jdbcType = JdbcType.VARCHAR),
            @Result(column = "mch_id", property = "mchId", jdbcType = JdbcType.BIGINT),
            @Result(column = "fail_reason", property = "failReason", jdbcType = JdbcType.VARCHAR),
            @Result(column = "sp_user_name", property = "spUserName", jdbcType = JdbcType.VARCHAR),
            @Result(column = "zfb_no", property = "zfbNo", jdbcType = JdbcType.VARCHAR)
    })
    List<Sp> selectByCondition(Map<String, Object> params);

    @SelectProvider(type = SpSqlProvider.class, method = "findByIdIn")
    @Results({
            @Result(column = "id", property = "id", jdbcType = JdbcType.BIGINT, id = true),
            @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
            @Result(column = "service", property = "service", jdbcType = JdbcType.VARCHAR),
            @Result(column = "bank", property = "bank", jdbcType = JdbcType.VARCHAR),
            @Result(column = "update_date", property = "updateDate", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "create_date", property = "createDate", jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "state", property = "state", jdbcType = JdbcType.TINYINT),
            @Result(column = "delete_flag", property = "deleteFlag", jdbcType = JdbcType.TINYINT),
            @Result(column = "card_no", property = "cardNo", jdbcType = JdbcType.VARCHAR),
            @Result(column = "mch_id", property = "mchId", jdbcType = JdbcType.BIGINT)
    })
    List<Sp> findByIdIn(List<Long> list, String key);

    @UpdateProvider(type= SpSqlProvider.class, method="updateState")
    int updateState(Sp record);
}